import axios from '@/api/interceptor';
import type { LoginForm, RegisterForm, UpdateForm } from '@/api/portal/types.ts';

export const login = async (formData:LoginForm) => {
  const result = await axios({
    url: '/portal/login',
    method: 'POST',
    data: formData
  });
  return result.data;
};

export const register = async (formData:RegisterForm) => {
  const result = await axios({
    url: '/portal/register',
    method: 'POST',
    data: formData
  });
  return result.data;
};


export const updateProfile = async (formData:UpdateForm) => {
  const result = await axios({
    url: '/portal/updateProfile',
    method: 'POST',
    data: formData
  });
  return result.data;
};

export const sendResetPasswordEmail = async (email:string) => {
  const result = await axios({
    url: `/portal/sendResetPasswordEmail?email=${email}`,
    method: 'POST',
  });
  return result.data;
};

export const resetPassword = async (token: string, password: string) => {
  const result = await axios({
    url: `/portal/resetPassword?token=${token}&password=${password}`,
    method: 'POST'
  });
  return result.data;
};


